package de.ttf.ts.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class Player extends AbstractPerson<Player> {
    private static final long serialVersionUID = 1L;

    @OneToMany
    @JoinTable(name = "PLAYER_TEAM", joinColumns = @JoinColumn(name = "PLAYER_ID"), inverseJoinColumns = @JoinColumn(name = "TEAM_ID"))
    private Set<Team> teams;

    @ManyToOne(optional = true)
    private Club club;
    
    @Temporal(TemporalType.DATE)
    private Date dateOfBirth;
    
    @Enumerated(EnumType.ORDINAL)
    @Column(nullable=false)
    private Gender gender;

    public Set<Team> getTeams() {
        if (teams == null) {
            teams = new HashSet<Team>();
        }
        return teams;
    }

    public Club getClub() {
        return club;
    }

    public void setClub(Club club) {
        this.club = club;
    }
    
    public Gender getGender() {
		return gender;
	}
    
    public void setGender(Gender gender) {
		this.gender = gender;
	}
    
    public Date getDateOfBirth() {
		return dateOfBirth;
	}
    
    public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}
}
